<template>
  <el-card class="box-card">
    <el-breadcrumb separator-class="el-icon-arrow-right">
      <el-breadcrumb-item style="font-size: 16px">首页</el-breadcrumb-item>
      <el-breadcrumb-item style="font-size: 16px">修改密码</el-breadcrumb-item>
    </el-breadcrumb>
    <div class="info">
      <h1>修改密码</h1>
      <div class="infoArea">
        <el-form
          :model="ruleForm"
          status-icon
          :rules="rules"
          ref="ruleForm"
          label-width="100px"
          class="demo-ruleForm"
        >
          <el-form-item label="旧密码" prop="oldPass">
            <el-input
              type="password"
              v-model="ruleForm.oldPass"
              autocomplete="off"
            ></el-input>
          </el-form-item>
          <el-form-item label="新密码" prop="newPass">
            <el-input
              type="password"
              v-model="ruleForm.newPass"
              autocomplete="off"
            ></el-input>
          </el-form-item>
          <el-form-item label="确认密码" prop="checkPass">
            <el-input
              type="password"
              v-model="ruleForm.checkPass"
              autocomplete="off"
            ></el-input>
          </el-form-item>
        </el-form>
      </div>
      <el-button type="primary" plain class="updateBtn">修改</el-button>
    </div>
  </el-card>
</template>

<script>
export default {
  data() {
    var validateoldPass = (rule, value, callback) => {
      if (value === "") {
        callback(new Error("请输入旧密码"));
      }
    };
    var validatenewPass = (rule, value, callback) => {
      if (value === "") {
        callback(new Error("请输入新密码"));
      }
    };
    var validatePass2 = (rule, value, callback) => {
      if (value === "") {
        callback(new Error("请再次输入密码"));
      } else if (value !== this.ruleForm.newPass) {
        callback(new Error("两次输入密码不一致!"));
      } else {
        callback();
      }
    };
    return {
      labelPosition: "right",
      ruleForm: {
        oldPass: "",
        newPass: "",
        checkPass: "",
      },
      rules: {
        oldPass: [{ validator: validateoldPass, trigger: "blur" }],
        newPass: [{ validator: validatenewPass, trigger: "blur" }],
        checkPass: [{ validator: validatePass2, trigger: "blur" }],
      },
    };
  },
};
</script>

<style scoped>
.box-card {
  /* position: relative; */
  /* left: 50%; */
  /* top: 50%; */
  /* margin-left: -500px; */
  /* margin-top: -275px; */
  width: 1000px;
  height: 550px;
  margin: 20px auto;
}
.text {
  font-size: 14px;
}

.item {
  padding: 18px 0;
}

.info {
  position: relative;
  width: 800px;
  top: 30px;
  left: 50%;
  margin-left: -400px;
  height: 400px;
  /* border: 1px solid red; */
}

.info h1 {
  position: absolute;
  display: inline-block;
  width: 100px;
  left: 50%;
  margin-left: -50px;
  height: 20px;
}

.infoArea {
  position: absolute;
  top: 100px;
  width: 490px;
  left: 50%;
  margin-left: -245px;
  height: 400px;
  /* border: 1px solid blue; */
}

.el-input {
  width: 300px;
}

.updateBtn {
  width: 150px;
  position: absolute;
  bottom: 10px;
  left: 50%;
  margin-left: -90px;
}
</style>